//  this library.
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hktk_app/util/view_util.dart';
import 'package:hktk_app/widget/subject/purchase_tips_widget.dart';

/// 资料预览遮罩组件
class PreviewMaskWidget extends StatelessWidget {
  /// 栏目id
  final String columnId;

  const PreviewMaskWidget({super.key, required this.columnId});

  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;
    double bottom = MediaQuery.of(context).padding.bottom;
    return Container(
      decoration: const BoxDecoration(color: colorWhite5),
      child: Stack(
        children: [
          _maskItem(
            svgUrl: "images/subject/preview_mask_1.svg",
            width: width,
            height: 666,
          ),
          _maskItem(
            svgUrl: "images/subject/preview_mask_2.svg",
            width: width,
            height: 538,
          ),
          _lockItem(bottom),
          _tipsItem(bottom),
        ],
      ),
    );
  }

  /// 遮罩背景
  _maskItem({
    required String svgUrl,
    required double width,
    required double height,
  }) {
    return Positioned(
      bottom: 0,
      child: SvgPicture.asset(
        svgUrl,
        width: width,
        height: height,
      ),
    );
  }

  /// 锁图标显示
  _lockItem(double bottom) {
    double bottom1 = bottom + 231;
    return Positioned(
      bottom: bottom1,
      left: 331,
      child: SvgPicture.asset(
        "images/subject/preview_mask_lock.svg",
        width: 88,
        height: 88,
      ),
    );
  }

  /// 提示显示
  _tipsItem(double bottom) {
    return PurchaseTipsWidget(
      tips: "购买立即解锁查看全部",
      columnId: columnId,
    );
  }
}
